package com.poseidon;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.alibaba.druid.pool.DruidDataSource;

public class DBLearn {

	public static void main(String[] args) throws Exception {
		@SuppressWarnings("resource")
		DruidDataSource dds = new DruidDataSource();
		dds.setUrl("jdbc:mysql://127.0.0.1:3306/pandora?characterEncoding=utf-8");
		dds.setUsername("root");
		dds.setPassword("root");
		Connection conn = dds.getConnection();
		String sql1 = "update staff set name = '张三三' where name = '张三' ";
		String sql2 = "update staff1 set name = '张三三' where name = '张三' ";

		try {
			PreparedStatement pst = conn.prepareStatement(sql1);
			int i = pst.executeUpdate();
			System.out.println(i);
			pst = conn.prepareStatement(sql2);
			int i2 = pst.executeUpdate();
			System.out.println(i2);
		} catch (Exception e) {
			conn.rollback();
			System.out.println("rooback");
		}
	}
}